import { createApp } from 'vue';
import { createPinia } from 'pinia';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';

import App from './App.vue';
import router from './router';

// import './assets/font/iconfont.css';
import './assets/style/base.less';
import 'element-plus/es/components/message/style/css';
import 'element-plus/es/components/alert/style/css';
import 'element-plus/es/components/dialog/style/css';
import 'element-plus/es/components/notification/style/css';

const app = createApp(App);
const pinia = createPinia();

pinia.use(piniaPluginPersistedstate);
app.use(pinia);
app.use(router);

// import * as ElementPlusIconsVue from '@element-plus/icons-vue';
// for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
//   app.component(key, component);
// }

app.config.globalProperties.$setImg = (url) => {
  return new URL(`/src/assets/images/${url}`, import.meta.url).href;
};

app.mount('#app');

if (import.meta.env.VITE_APP_ENV === 'development') {
  import('vconsole').then(({ default: VConsole }) => {
    // eslint-disable-next-line no-new
    new VConsole();
  });
}

export default app;
